//
//@File    :	13.11_acctabc.h
//@Time    :	2021/09/20 17:04:52
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	bank account classes
//

#ifndef ACCTABC_H_
#define ACCTABC_H_
#include <iostream>
#include <string>
//Abstract Base Class
class AcctABC
{
private:
    std::string fullName;
    long acctNum;
    double balance;
protected:
//对于类外来说,保护成员相当于私有成员
//对于派生类来说,保护成员相当于公有成员
    
    //定义一个结构,用来储存两项格式设置,并使用该结构设置和回复格式
    struct Formatting
    {
        std::ios_base::fmtflags flag;
        std::streamsize pr;
    };
    const std::string & FullName() const {return fullName;}
    long AcctNum() const {return acctNum;}
    Formatting SetFormat() const;
    void Restore(Formatting & f) const;

public:
    AcctABC(const std::string & s="Nullbody",long an=-1,double bal=0.0);
    void Deposit(double amt);
    virtual void Withdraw(double amt)=0;//pure virtual function
    double Balance() const {return balance;};
    virtual void ViewAcct() const=0;//pure virtual function
    ~AcctABC() {}
};


//Brass Account Class
class Brass:public AcctABC
{
public:
    Brass(const std::string & s="Nullbody",long an=-1,double bal=0.0)
        :AcctABC(s,an,bal) {}
    virtual void Withdraw(double amt);
    virtual void ViewAcct() const;
    virtual ~Brass() {}
};

//Brass Account Class
class BrassPlus:public AcctABC
{
private:
    double maxLoan;
    double rate;
    double owesBank;
public:
    BrassPlus(const std::string &s="Nullbody",long an=-1,double bal=0.0,double ml=500,double r=0.10);
    BrassPlus(const Brass &ba,double ml=500,double r=0.1);
    virtual void ViewAcct() const;
    virtual void Withdraw(double amt);
    void RestMax(double m){maxLoan=m;}
    void RestRate(double r){rate=r;};
    void RestOwes(){owesBank=0;}
};
#endif	// ACCTABC_H_